Repository navigation
Preserve tuple cotangent types in ChainRules pullbacks - #329
Merged
Merged
Conversation
lkdvos
enabled auto-merge (squash)
November 19, 2026 02:07
Yue-Zhengyuan
disabled auto-merge
November 19, 2026 02:29
Member
Author
|
Just find out that first explicitly unpack the cotangent also works: ΔU, ΔS, ΔVᴴ = ΔUSVᴴ′
ΔUSVᴴ = map(unthunk, (ΔU, ΔS, ΔVᴴ))This may be more readable. @lkdvos Which approach do you prefer? |
Jutho
approved these changes
Nov 19, 2026
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
lkdvos
approved these changes
Nov 19, 2026
lkdvos
left a comment
Member
There was a problem hiding this comment.
Don't really have a strong preference, but it's nice to not have to use the backing, so I like this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Broadcasting
unthunkover a tuple cotangent wrapped inTangentcollects its components into a vector, losing their individual types. Unpack the cotangent in the pullback argument before mappingunthunkto preserve concrete component types.Argument unpacking also preserves support for a thunk around the entire cotangent container: ChainRulesCore's iteration methods evaluate the outer thunk, while
map(unthunk, ...)evaluates any component thunks.The tuple-preserving materialization is applied to QR, LQ, eigen, SVD, and polar pullbacks.